from django.db import models


# Create your models here.
class BooktestAreainfo(models.Model):
    atitle = models.CharField(max_length=20, verbose_name='标题')
    aparent = models.ForeignKey('self', models.DO_NOTHING, db_column='aParent_id', blank=True, null=True, verbose_name='父级单位')  # Field name made lowercase.

    def __str__(self):
        return self.atitle

    def title(self):
        return self.atitle
    title.admin_order_field = 'atitle'  # 设置方法title能够在管理界面中有排序的效果
    title.short_description = '地区名称'  # 设置标题的名称

    def parent(self):
        if self.aparent is None:
            return 'null'
        return self.aparent.atitle
    parent.short_description = '父级单位'  # 设置标题的名称

    class Meta:
        # managed = False
        db_table = 'booktest_areainfo'
